﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>基础资料修改流程</title>
    <link rel="stylesheet" type="text/css" href="../../Portal/icons/font-icons.min.css" />
    <script type="text/javascript" src="../../Portal/js/sortjs/Sortable.min.js"></script>
    <!--- 引入代码. -->
    <script src="../../Scripts/jquery/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Portal/js/vue/vue.js"></script>
    <script src="../../Scripts/layui/LayuiDialog.js"></script>
    <script src="../../Scripts/layui/layui/layui.js"></script>
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <style>
        .method {
            width: 100%;
        }

            .method .row {
                display: flex;
                justify-content: flex-start;
                flex: 0.2;
                height: 40px;
                line-height: 40px;
                background-color: #FAFAFA;
            }

                .method .row .item {
                    box-sizing: border-box;
                    flex-shrink: 0;
                    text-align: center;
                    border-right: 1px solid #eee;
                    border-bottom: 1px solid #eee;
                }

        .item-name {
            width: 30%;
            text-overmethod: ellipsis;
            white-space: nowrap;
            cursor: pointer;
            padding-left: 5px;
            overflow: hidden
        }

        .item-num {
            width: 8%;
            align-items: center;
            justify-content: center;
        }

        .item-other {
            width: 10%;
            align-items: center;
            justify-content: center;
            overflow: hidden
        }

        .item-docs {
            width: 30%;
            display: flex;
            align-items: center;
            justify-content: center;
        }


        .item-index {
            background-color: #FAFAFA;
            padding-right: 40px;
            color: #999999
        }

        .method .row .folder-item {
            box-sizing: border-box;
            width: 74%;
            padding-left: 20px;
            cursor: pointer;
        }

        .wrapper .row {
            background-color: #fff;
        }

        #s-main {
            transition: all ease .4s;
            margin-top: 40px;
        }

        .fixed {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
        }

        [v-cloak] {
            display: none;
        }

        .layui-input-block > .layui-form-switch {
            margin-top: 0 !important;
        }
    </style>
    <style id="theme-data">
    </style>
</head>
<body>

    <div class="method" id="method">
        <div class="layui-full" style="margin-top:10px;">
            <div class="layui-row">
                <div class="layui-col-sm6 layui-col-xs6">
                    <div class="layui-inline">
                        <input type="text" id="TB_Key" name="TB_Key" class="layui-input layui-col-sm4" placeholder="关键字" />
                    </div>
                    <button @click.stop="Search()" class="layui-btn layui-btn-sm"> 查询</button>
                    <button onclick="StartIt()" class="layui-btn layui-btn-sm">新建</button>

                </div>
                <div class="layui-col-sm6 layui-col-xs6" style="text-align:right">
                    <button onclick="SearchAdv()" class="layui-btn layui-btn-sm">高级查询</button>
                </div>

            </div>
        </div>
        <div class="row" style="margin-top:10px;">
            <div class="item item-other">#</div>
            <div class="item item-other">单号</div>

            <div class="item item-other">状态</div>
            <div class="item item-name"><i class="icon-app"></i> 标题</div>
            <div class="item item-other">创建人</div>
            <div class="item item-other">创建日期</div>
            <div class="item item-other">参与人</div>
            <div class="item item-other">优先级</div>
        </div>

        <div>
            <div class="row" v-for="(gwf,idx) in gwfs" :key="idx" :data-id="gwf.WorkID">
                <div class="item item-other" style="text-align: right;">{{idx + 1}}</div>

                <div class="item item-other" style="text-align: right;">{{gwf.BillNo}}</div>
                <div class="item item-other" style="text-align: right;">{{idx + 1}}</div>
                <div class="item item-name" style="text-align: left" :data-mypk="gwf.WorkID" :data-name="gwf.Title"
                     :data-idx="idx" @click.stop="OpenMyView(gwf.FK_Flow,gwf.WorkID)">
                    <span> <font color="blue">{{gwf.Title}}</font></span>
                </div>
                <div class="item item-other">{{gwf.StarterName}}</div>
                <div class="item item-other">{{gwf.RDT}}</div>
                <div class="item item-other">
                    {{gwf.NodeName}}
                </div>
                <div class="item item-other"><i :class="gwf.Icon"></i> {{gwf.IconTitle}}</div>
            </div>
        </div>

    </div>
    <script type="text/javascript">
        $(function () {

            //var handler = new HttpHandler("BP.CCBill.WF_CCBill_OptOneFlow");
            //handler.AddUrlData();
            //var data = handler.DoMethodReturnString("FlowBaseData_Init");
            //if (data.indexOf('err@') == 0) {
            //    alert(data);
            //    return;
            //}
        });

        new Vue({
            el: '#method',
            data: {
                gwfs: [], //工作流实例集合.
                expandAll: false,
                loadingDialog: false
            },
            watch: {
                expandAll(val) {
                    this.expandMenus(val);
                }
            },
            methods: {

                startList: function () {
                    var frmID = GetQueryString("FrmID");
                    var workID = GetQueryString("WorkID");
                    if (workID == null)
                        workID = 0;

                    var ens = new Entities("BP.CCBill.GenerBills");
                    ens.Retrieve("PWorkID", workID, "PFrmID", frmID, "RDT");
                    mapAttrs = obj2arr(ens);
                    //console.log(ens);
                    for (var i = 0; i < ens.length; i++) {


                        if (this.ens[i].BillState <= 0) continue; //草稿与空白的
                        var gwf = this.ens[i];
                        //退回的.
                        if (gwf.BillState === 1) { gwf.Icon = "icon-clock"; gwf.IconTitle = "草稿"; }//运行中的.
                        if (gwf.BillState === 2) { gwf.Icon = "icon-check"; gwf.IconTitle = "编辑中"; }//已完成的.
                        if (gwf.BillState === 100) { gwf.Icon = "icon-action-undo"; gwf.IconTitle = "归档"; } //退回的.
                    }
                    this.gwfs = ens;
                },
                Search: function () {
                    this.startList();
                    this.searchKey = $("#TB_Key").val();
                    venss = [];
                    for (var i = 0; i < this.gwfs.length; i++) {

                        var Titlebj = this.gwfs[i].Title;
                        if (Titlebj.indexOf(this.searchKey) == -1) continue;
                        venss[i] = this.gwfs[i];
                    }
                    console.log(venss);
                    this.gwfs = venss;
                },
                OpenMyView: function (flowNo, workid) {

                    var handler = new HttpHandler("BP.WF.HttpHandler.WF_MyView");
                    handler.AddPara("WorkID", workid);
                    handler.AddPara("FK_Flow", flowNo);
                    var data = handler.DoMethodReturnString("MyView_Init");
                    if (data.indexOf('err@') == 0) {
                        $("#Msg").html("<br>" + data);
                        return;
                    }
                    if (data.indexOf('url@') == 0) {

                        data = data.replace('url@', ''); //如果返回url，就直接转向.
                        data = data.replace('?DoType=HttpHandler', '?');
                        data = data.replace('&DoType=HttpHandler', '');
                        data = data.replace('&DoMethod=MyView_Init', '');
                        data = data.replace('&HttpHandlerName=BP.WF.HttpHandler.WF_MyCC', '');
                        data = data.replace('?&', '?');
                        //如果返回url，就直接转向.
                        SetHref("../../" + data);
                        return;
                    }
                }
            },
            mounted: function () {

                // fix firefox bug
                document.body.ondrop = function (event) {
                    event.preventDefault();
                    event.stopPropagation();
                }


                this.startList();

            }
        })

        function obj2arr(obj) {
            delete obj.Paras
            delete obj.ensName
            delete obj.length
            var arr = []
            for (var key in obj) {
                if (Object.hasOwnProperty.call(obj, key)) {
                    arr.push(obj[key]);
                }
            }
            return arr
        }
        //创建单据， 把当前表单的数据传入进去..
        function StartIt() {

            var methodNo = GetQueryString("MethodNo");
            var workID = GetQueryString("WorkID");
            workID = parseInt(workID);

            //如果是创建单据.
            var en = new Entity("BP.CCBill.Template.MethodBill", methodNo);
            var billWorkID = en.DoMethodReturnString("CreateWorkID", workID);
            if (billWorkID.indexOf('err@') == 0) {
                alert(billWorkID);
                return;
            }

            var url = "../../CCBill/MyBill.htm?FK_Flow=" + en.FlowNo + "&FrmID=" + en.Tag1 + "&WorkID=" + billWorkID + "&FK_Node=0&MethodNo=" + methodNo + "&PWorkID=" + workID;
            SetHref(url);
        }

        //查询
        function Search() {
            //对this.gwfs 的数据 的Title 进行过滤匹配,从新绑定表格.
            var key = $("#TB_Key").val();
            if (key == "" || key == undefined)
                return;

        }

        //高级查询, 转入到单据查询上去.
        function SearchAdv() {
            var url = "";
            url = "./SearchBill.htm?FrmID=" + GetQueryString("FrmID");
            url += "&PWorkID=" + GetQueryString("PWorkID");
            url += "&MothodNo=" + GetQueryString("MothodNo");
            //
            //window.location.href = filterXSS(url);
            addTab(url, GetQueryString("FrmID") + '高级查询')
        }

        function addTab(url, title = '高级查询') {
            window.top.vm.openTab(title, url, true);
        }
    </script>
    <script>
        $(function () {
            if (CustomerNo != "" && CustomerNo != null) {
                var html = "\n .layui-btn{\n background-color:'#5053f1';\n}\n .layui-laypage .layui-laypage-curr .layui-laypage-em{\n background-color:'#5053f1';\n}";
                html += "\n .layui-laypage input:focus,.layui-laypage select:focus{\n border-color:'#5053f1' !important\n}";
                html += "\n .layui-form-select dl dd.layui-this{\n background-color:#5053f1' !important;\n}";
            }
            var theme = DealText(localStorage.getItem("themeColorInfo"));
            if (theme == null || theme == undefined || theme == "")
                return;
            theme = JSON.parse(theme);
            var styleScope = document.getElementById("theme-data");

            var html = "\n .layui-btn{\n background-color:" + theme.selectedMenu + ";\n}\n .layui-laypage .layui-laypage-curr .layui-laypage-em{\n background-color:" + theme.selectedMenu + ";\n}";
            html += "\n .layui-laypage input:focus,.layui-laypage select:focus{\n border-color:" + theme.selectedMenu + " !important\n}";
            html += "\n .layui-form-select dl dd.layui-this{\n background-color:" + theme.selectedMenu + " !important;\n}";

            styleScope.innerHTML = DealText(html);

        })
    </script>
</body>
</html>